<?php

declare(strict_types=1);

namespace app\index\controller;

use app\model\Topic;
use think\Request;

class System extends Common
{
  public function resetCount()
  {
    // 
    $this->countTopic();
  }

  public function countTopic()
  {
   Topic::chunk(100, function ($topics) {
      foreach ($topics as $topic) {
        // 处理结果集...
        $new_topic = $topic->resetThisCount();

        dump('话题数据:'.$new_topic->title.',文章数:'.$new_topic->post_count.',访问数:'.$new_topic->hits_count);
      }
    });
  }
}
